package org.veridiandynamics.server.domain;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

/**
 * Class containing specific instances of a role and its id.
 *
 */
public class Roles implements PersistObject, Serializable
{

	private long id;
	public int role;
	private static final long serialVersionUID = 80L;
	
	public Roles(RoleLookup.Role role) {
		if (role.equals(RoleLookup.Role.PATIENT)) {
			this.role = 10;
		}
		else if(role.equals(RoleLookup.Role.NURSE)) {
			this.role = 20;
		}
		else if(role.equals(RoleLookup.Role.DOCTOR)) {
			this.role = 30;
		}
		else if(role.equals(RoleLookup.Role.ADMIN)) {
			this.role = 40;
		}
	}
	

	/**
	 * Default constructor
	 */
	public Roles(){}
	
	/**
	 * Gets ID.
	 * @return ID for Roles object.
	 */
	public long getId() {
		return id;
	}

	/**
	 * Sets ID.
	 * @param id
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * Returns Role.
	 * @return
	 */
	public int getRole() {
		return role;
	}

	/**
	 * Sets role.
	 * @param role
	 */
	public void setRole(int role) {
		this.role = role;
	}
	
	/**
	 * Writes object.
	 * 
	 * @param outputStream
	 * @throws IOException
	 */
	private void writeObject(ObjectOutputStream outputStream) throws IOException {
		outputStream.defaultWriteObject();
	}
	
	/**
	 * Reads object.
	 * 
	 * @param inputStream
	 * @throws ClassNotFoundException
	 * @throws IOException
	 */
	private void readObject(ObjectInputStream inputStream) throws ClassNotFoundException, IOException {
		inputStream.defaultReadObject();
	}
}
